package domain;

import java.sql.*;

public class JDBCUntis {



  public static Connection getconnection() {
    Connection conn = null;
//    propertiesUtils.getproperties("db.properties");
//    String dirver = propertiesUtils.getPropertiesVale("dirver.class");
//    String url = propertiesUtils.getPropertiesVale("url.class");
//    String username = propertiesUtils.getPropertiesVale("username.class");
//    String password = propertiesUtils.getPropertiesVale("passworld.class");

    try {
      //        Class.forName("com.mysql.jdbc.Driver");
      //        String url="jdbc:mysql://localhost:3306/java?useSSL=false";
      //        String name="root";
      //        String pas="123456";
     // Class.forName(dirver);
    //  conn = DriverManager.getConnection(url, username, password);
      //连接池 Druid
      conn = Druiddb.ds.getConnection();

    } catch (Exception e) {
      e.printStackTrace();
    }
    return conn;
  }

  public static void closet(Connection conn, Statement st, ResultSet rs) {
    try {
      if (rs != null) {
        rs.close();
      }

    } catch (SQLException throwables) {
      throwables.printStackTrace();
    } finally {
      try {
        if (st != null) {
          st.close();
        }

      } catch (SQLException throwables) {
        throwables.printStackTrace();
      } finally {
        try {
          if (conn != null) {
            conn.close();
          }

        } catch (SQLException throwables) {
          throwables.printStackTrace();
        }
      }
    }
  }
}
